from sklearn.model_selection import StratifiedShuffleSplit, GridSearchCV
from time import time
import numpy as np
from sklearn.svm import SVC
import datetime


time0 = time()

degree_range = np.logspace(0, 30, 31)
gamma_range = np.logspace(-10, 5, 20)
coef0_range = np.linspace(0, 5, 10)

param_grid = dict(
    gamma = gamma_range,
    coef0 = coef0_range,
    degree = degree_range
)

cv = StratifiedShuffleSplit(n_splits=5, test_size=0.3, random_state=420)
grid = GridSearchCV(SVC(kernel="poly"),
                    param_grid=param_grid, cv=cv)

X = np.loadtxt("data/X/data.csv", delimiter=",")
y = np.loadtxt("data/target/data.csv", delimiter=",")

grid.fit(X, y)
print((grid.best_params_, grid.best_score_))
print(datetime.datetime.fromtimestamp(time()-time0).strftime("%M:%S:%f"))
